<?php
require "model/log.model.php";
session_start();
header("content-type:text/html;charset=utf-8");
if(!empty($_POST["username"])){
$username = $_POST["username"];
$password = $_POST["password"];
$re = login::do_log($username,$password);
if($re){
	$_SESSION['username']=$username;
	echo "<script>alert('登入成功');parent.location.href='./index.php';</script>";
}
else{	
    echo "<script>alert('用户名或密码错误');parent.location.href='login.php';</script>";
}
require "view/login.tpl.php";
}else{
	require "view/login.tpl.php";
}

?>